package com.qianfeng.listviewdemo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * Created by jackiechan on 16/3/11 上午11:02.
 * 版本: 1
 * 公司:北京千锋互联科技有限公司
 */
public class MyAdapter extends BaseAdapter {
    private Context context;
    private int num;
    public MyAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        return num;
    }

//    public int getNum() {
//        return num;
//    }

    public void setNum(int num) {
        this.num = num;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
//        Log.e("自定义标签", "getView() called with: " + "position = [" + position + "], convertView = [" + convertView + "]");
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item, null);
        }
        TextView t = (TextView) convertView.findViewById(R.id.tv);
        t.setTag("tv" + position);
        t.setText("这是第" + position);
        return convertView;
    }
}
